package com.github.pig.admin.controller.dict;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.github.pig.admin.model.entity.SysDict;
import com.github.pig.admin.service.dict.SysDictService;
import com.github.pig.common.web.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * <p>
 * 前端控制器-字典
 * </p>
 *
 * @author xiaosa
 * @since 2018-06-04
 */
@Controller
@RequestMapping("/dict")
public class DictController extends BaseController {

    @Autowired
    private SysDictService dictService;

    /**
     * 根据字典类别获取字典项
     * @return 小区列表
     */
    @GetMapping("/{type}")
    @ResponseBody
    public List<SysDict> getDicts(@PathVariable String type) {
        EntityWrapper entityWrapper = new EntityWrapper();
        entityWrapper.eq("type",type);
        entityWrapper.orderBy("sort",true);
        return dictService.selectList(entityWrapper);
    }



}
